package com.controller;

import com.Result.CommentResult;
import com.entity.TwitterComment;
import com.mapper.TwitterCommentMapper;
import com.service.TwitterCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/twitterComment")
@Api(tags = "朋友圈评论点赞管理器")
public class TwitterCommentController {
    @Autowired
    private TwitterCommentService twitterCommentService;

    @GetMapping("/getAll")
    @ApiOperation(value = "获取表中所有信息")
    public List<TwitterComment> getAll() {
        return twitterCommentService.list();
    }

    @GetMapping("/getByTwitterId")
    @ApiOperation(value = "根据朋友圈id获取评论点赞信息")
    public CommentResult getByTwitterId(Integer twitterId) {
        return twitterCommentService.getByTwitterId(twitterId);
    }

    @GetMapping("/commentForTwitter")
    @ApiOperation(value = "评论朋友圈")
    public boolean commentForTwitter(Integer twitterId, Integer userId, String comment) {
        return twitterCommentService.commentForTwitter(twitterId, userId, comment);
    }

    @GetMapping("/deleteComment")
    @ApiOperation(value = "删除评论")
    public boolean deleteComment(Integer commentId) {
        return this.twitterCommentService.removeById(commentId);
    }

    @GetMapping("/thumbsUpForTwitter")
    @ApiOperation(value = "点赞朋友圈")
    public boolean thumbsUpForTwitter(Integer twitterId, Integer userId) {
        return this.twitterCommentService.thumbsUpForTwitter(twitterId, userId);
    }

    @GetMapping("/thumbsDownForTwitter")
    @ApiOperation(value = "取消点赞")
    public boolean thumbsDownForTwitter(Integer twitterId, Integer userId) {
        return this.twitterCommentService.thumbsDownForTwitter(twitterId, userId);
    }
}
